from time import sleep

from selenium.webdriver.common.by import By

from base.base import Base


class MQEPage(Base):
    goods_manager = (By.XPATH, '//span[text()="商场管理"]')

    def gm_f(self):
        self.loc_wait_ele(self.goods_manager).click()

    bp = (By.XPATH, '//span[text()="通用问题"]')

    def bp_f(self):
        self.loc_wait_ele(self.bp).click()

    ab = (By.XPATH, '//span[text()="编辑"]')

    def ab_f(self):
        self.loc_wait_ele(self.ab).click()

    bn=(By.XPATH,'//div[@class="el-form-item__content"]/div/input')
    def bu_f(self, n):
        self.loc_wait_ele(self.bn).send_keys(n)

    dp = (By.CSS_SELECTOR,
          "#app > div > div.main-container > section > div > div.el-dialog__wrapper > div > div.el-dialog__body > form > div:nth-child(2) > div > div > textarea")

    def dp_f(self, i):
        self.loc_wait_ele(self.dp).send_keys(i)

    cb = (By.XPATH, '//div[@class="dialog-footer"]/button[2]')

    def cb_f(self):
        self.loc_wait_ele(self.cb).click()

    dy = (By.XPATH, '//table[@class="el-table__body"]/tbody/tr[1]/td[2]/div')

    def gdc(self):
        return self.loc_wait_ele(self.dy).text

    dialog = (By.CSS_SELECTOR, "body > div.el-notification.right > div > div.el-notification__content > p")

    def dialog_f(self):
        r=self.loc_wait_ele(self.dialog).text
        print("获取元素：",r)
        return r


    def mqe_bus(self,n,i):
        self.gm_f()
        self.bp_f()
        self.ab_f()

        self.bu_f(n)
        self.dp_f(i)

        self.cb_f()
        sleep(2.5)

        #return self.gdc()
        return self.dialog_f()



